1. Field of the Invention
The present invention relates to data synchronization between server computers and client computers. More particularly, the invention relates to tracking and collecting changes in a server database and one or more client databases and synchronizing in accordance with relevant changes.
2. Description of Relevant Art
Databases that are stored in central computer server systems may be partially duplicated or copied in client computers that may not always be online. Consequently there arises a need for database synchronization between the database server system and one or more client computers, and the synchronization may involve changes in both directions, i.e. changes may have been made to the data on the client computers as well as on the server system. In addition to data that should be transferred to a client because the data has changed on the server, it may be necessary to transfer data that has not been changed but that has become relevant to a client some time after the previous synchronization as a result of some other change in the database. In other words, in addition to updating the client with data records that have been changed on the server, some records that have not been changed on the server may nevertheless have to be deleted from or added to a client computer.
An example may involve mobile devices that contain a partial database representing stock inventory of a store. The devices may be used to take inventory or register necessary purchases to resupply. It will then readily be understood that changes may have been made to the list of available products registered in the central database since a mobile device was last synchronized. Similarly, changes may have been made to the mobile device representing an actual inventory registered by an employee in the store, or an order to make a purchase to restock a particular good. In addition, changes may have been made that changes which part of the data available from the central database is relevant to the partial database on the client device.
For example, a client device may have been used to take inventory in a hardware department and a sports department of a store and consequently having been updated with a partial database including hardware products and sports products. At a subsequent occasion the same device may be reassigned to register necessary purchases in a clothing department of the same store, while it is no longer used in the hardware department. A synchronization of the client with the database should then remove the part of the database that relates to hardware products, add the part of the database that relates to sports products, and makes all necessary updates resulting from changes to the list of clothing products in the central database.
A brute force solution to the problem of synchronizing clients is to first import all updates that have been made on the client to the database, then delete all database data on the client, and finally export the entire database or partial database to the client again. This ensures that all data on the client are current as of the time of synchronization, but it requires a lot of data transfer, and may also interfere with system's ability to handle interaction with other clients while synchronization is performed. It should be noted that the terms import and export will be used relative to the main (server) database unless otherwise noted. Thus, import, or import to, refers to the introduction of new data to the database from a client, while export, or export from, means introducing or updating data from the server database to a client database.
An alternative that has been proposed is to maintain a database log of all updates to all records in the main database, and to base synchronization on this log. If the state of the database at the previous synchronization is known and all database transactions between the previous synchronization and the ongoing synchronization is known, it is possible to update the client based on the log of changes and without interfering with the actual database. Based on the log a summary of all changes to the database between two synchronizations can be created. This summary can be thought of as a database Δ, the difference in the database between two synchronizations.
Using the database Δ to update the clients is fairly straightforward if the clients contain complete copies of the main database. In that case the client should be updated with the entire database Δ; all changes should be sent to the client. However, if the client only contains a partial database, it is necessary to identify the records in the database Δ that are relevant to the particular client that is being synchronized, and only transfer those. In addition, it may be necessary to transfer records that have not changed, i.e. that are not part of the database Δ, but that become necessary to the client for other reasons.
An unchanged record may have become relevant to a client for different reasons. Generally speaking, two classes of reasons can be identified, and they may be referred to as internal reasons and external reasons. Internal reasons include cases where a change in one record (a record that is part of the database Δ) makes it necessary to import additional (unchanged) records to the client in order to fulfill constraints and ensure that relevant data is actually present on the client. External reasons include cases where some fact external to the database itself makes it appropriate to import a record to the client, for example a particular point in time. An example of the latter could be a work order that was prepared even at the previous synchronization, but that should not be transferred to the client until the day before the work is due to be performed.
For similar reasons, records that were relevant to the partial database in the client at the previous synchronization, may have become irrelevant even if the record itself has not changed, and it may consequently be necessary to remove unchanged records.
Consequently there is a need for methods and systems that are able to perform incremental synchronization of partial databases while fulfilling constraints.